package com.service.impl;

import com.dao.BuildingDao;
import com.pojo.Building;
import com.service.BuildService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class BuildServiceImpl implements BuildService {

    @Autowired
    BuildingDao buildingDao;

    /**
     * 查询宿舍楼以及对应的宿管
     */
    @Transactional
    @Override
    public List<Building> FindAllBuild() {
        return buildingDao.findAllBuild();
    }


    /**
     * 添加楼宇
     *
     * @param build
     * @return
     */
    @Transactional
    @Override
    public Integer addBuild(Building build) {
        return buildingDao.insert(build.getName());
    }



    /**
     * 添加楼和管理员对应
     *
     * @param id
     * @return
     */
    @Transactional
    @Override
    public Integer addBuildAdmin(String id, String adminid) {
        return buildingDao.addBuildAdmin(id,adminid);
    }

    @Transactional
    @Override
    public Integer DeleteBuild(String id) {
        return buildingDao.delete(id);
    }

    @Transactional
    @Override
    public Integer DeleteBuildEmp(String id) {
        return buildingDao.DeleteBuildEmp(id);
    }

    @Transactional
    @Override
    public Integer updateBuild(Building building) {
        return buildingDao.updateById(building);
    }

    @Transactional
    @Override
    public Integer updateBuildEmp(String id, String eid) {
        return buildingDao.updateBuildEmp(id,eid);
    }

    @Transactional
    @Override
    public Building selectByName(String name) {
        Building building = buildingDao.selectByName(name);
        return building;
    }


}
